package com.salt.modules.sys.service;

import com.alibaba.fastjson.JSONObject;
import com.salt.common.json.AjaxJson;
import com.salt.common.service.CrudService;
import com.salt.common.utils.StringUtils;
import com.salt.modules.sys.entity.Industry;
import com.salt.modules.sys.mapper.IndustryMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * @Description
 * @Author salt
 * @Date 2022/8/23
 * @Version 1.0.1
 */
@Service
@Transactional(readOnly = true)
public class IndustryService extends CrudService<IndustryMapper, Industry> {

    @Transactional(readOnly = false, rollbackFor = Exception.class)
    public AjaxJson batchDelete(String idsJson) {
        if (StringUtils.isNotBlank(idsJson)) {
            List<String> ids = Arrays.asList(idsJson.split(","));
            mapper.batchDelete(ids);
            return AjaxJson.success("删除成功!");
        }
        return AjaxJson.error("删除失败!");
    }
}
